# Maintainer: David Runge <dvzrv@archlinux.org>

_name=cfgv
pkgname=python-cfgv
pkgver=3.3.1
pkgrel=4
pkgdesc="Validate configuration and produce human readable error messages"
arch=('any')
url="https://github.com/asottile/cfgv"
license=('MIT')
depends=('python')
makedepends=('python-setuptools')
checkdepends=('python-pytest')
# pypi sdist tarballs don't contain tests:
# https://github.com/asottile/cfgv/issues/23
# source=("https://files.pythonhosted.org/packages/source/${_name::1}/${_name}/${_name}-${pkgver}.tar.gz")
source=("${_name}-${pkgver}.tar.gz::https://github.com/asottile/${_name}/archive/v${pkgver}.tar.gz")
sha512sums=('59c358bab9f2b32a1ac6eb72bba67b76e8368e0cf78c32228a6add200a0205f698aa80d9bd1b1e8701fb699b9599c88a240f76e2c91a602a0c292a67693e6857')
b2sums=('8727a9886334a1fe59aeb0554c4c53139ae7e1f66534102c67f005d66dc1f78cff5e5534468a10b85df645f7e8a2fc72ca6ca2e448d09cb7636d08e8b3843113')

prepare() {
  mv -v "${_name}-${pkgver}" "$pkgname-$pkgver"
}

build() {
  cd "$pkgname-$pkgver"
  python setup.py build
}

check() {
  cd "$pkgname-$pkgver"
  export PYTHONPATH="build:${PYTHONPATH}"
  pytest -v
}

package() {
  cd "$pkgname-$pkgver"
  python setup.py install --skip-build \
    --optimize=1 \
    --root="${pkgdir}"
  install -vDm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -vDm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
}
